package com.jl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jl.commons.result.PageDataInfo;
import com.jl.mapper.DeviceComponentMapper;
import com.jl.model.DeviceComponent;
import com.jl.service.IDeviceComponentService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 设备中的配件表(绑定具体设备) 服务实现类
 * </p>
 *
 * @author JiangJian
 * @since 2019-04-24
 */
@Service
public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMapper, DeviceComponent> implements IDeviceComponentService {


    @Override
    public void getDeviceComponentDataGrid(PageDataInfo<Map<String, Object>> pageDataInfo, QueryWrapper<DeviceComponent> qw) {
        Page<Map<String,Object>> page = new Page<>();
        page.setSize(pageDataInfo.getSize());
        page.setCurrent(pageDataInfo.getCurrent());
        List<Map<String,Object>> mapList =baseMapper.selectDataGrid(page,qw);
        pageDataInfo.setTotal(page.getTotal());
        pageDataInfo.setRecords(mapList);
    }

    @Override
    public void getDeadLineComponent(PageDataInfo<Map<String, Object>> pageDataInfo, Integer days) {
        Page<Map<String,Object>> page = new Page<>();
        page.setSize(pageDataInfo.getSize());
        page.setCurrent(pageDataInfo.getCurrent());
        List<Map<String,Object>> mapList =baseMapper.selectDeadLineComponent(page,days);
        pageDataInfo.setTotal(page.getTotal());
        pageDataInfo.setRecords(mapList);
    }
}
